d={10:"cat",20:" dog",10:"big"}
print(d)   # key 相同时 值会被覆盖


lst1=[10,20,30,40]
lst2=["cat","dog","big"]
j=zip(lst1,lst2)
print(j)
#print(list(j))  #转成列表类型 再转就不行了
d=dict(j)
print(d)

d=dict(cat=10,dog=52)
print(d)

t=(10,20,30)     #列表可以被修改不能做key
print({t:888})

print("max:",max(d))
print("min:",min(d))
print("len:",len(d))

del d  #删除了
#print(d)  #输出就报错了
print("\n"+"*"*40)
d={"hello":10,"world":20,"pathon":30}
print(d["hello"])
print(d.get("hello"))
#print(d['fjsdal'])
print(d.get("fjasij","没有"))  #可以引字典中不存在的key并返回None或者自定义的

for i in d.items():
    print(i)
for i,j in d.items():
    print(i,"-->",j)

d["c++"]=50
print(d)
print(d.keys())
print(list(d.keys()))
print(tuple(d.keys()))

print(d.values())

print(d.pop("c++"))
print(d)

print(d.pop("dkf","不存在"))

print(d.popitem()) #随机删除
print(d)

d.clear()
print(d)
print(bool(d)) #空字典的布尔值为False

#字典生成式
import random
d={i:random.randint(1,100) for i in range(4)}
print(d)

lst1=[10,20,30]
lst2=["c++","python","dfs"]
d={i:j for i,j in zip(lst1,lst2)}
print(d,type(d))